We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | define( |
||
3 | function(Module, _, Mn, PaymentModel, Template, Controller, Handlebars) { |
||
4 | "use strict"; |
||
5 | |||
6 | return Module.extend({ |
||
7 | regions: { |
||
8 | 'paymentMethodData': '#payment-method-settings', |
||
9 | 'paymentMethodList': '.left-sidebar' |
||
10 | }, |
||
11 | initialize: function() { |
||
12 | var module = this; |
||
13 | |||
14 | var model = new PaymentModel, |
||
|
|||
15 | controller = new Controller(module, model); |
||
16 | |||
17 | Handlebars.registerPartial('menuItem', Template.payment.menu_item); |
||
18 | |||
19 | var view = Mn.View.extend({ |
||
20 | template: Template.payment.menu, |
||
21 | el: '#payment-method-tabs', |
||
22 | router: null, |
||
23 | modelEvents: { |
||
24 | sync: 'render' |
||
25 | }, |
||
26 | initialize: function() { |
||
27 | this.model.fetch({success: _.bind(this.setRoutes, this)}); |
||
28 | }, |
||
29 | setRoutes: function() { |
||
30 | var router = this.getOption('router'), |
||
31 | enabled = _.clone(this.model.get('enabled')), |
||
32 | disabled = _.clone(this.model.get('disabled')); |
||
33 | |||
34 | var initialRoute = _.head(_.values(enabled)); |
||
35 | |||
36 | if (_.isUndefined(initialRoute)) { |
||
37 | initialRoute = _.head(_.values(disabled)); |
||
38 | } |
||
39 | |||
40 | _.each(_.merge(enabled, disabled), function(item) { |
||
41 | router.appRoute(item, 'showMethod'); |
||
42 | }); |
||
43 | |||
44 | setTimeout(function() { |
||
45 | controller.showMethod(initialRoute); |
||
46 | }, 0); |
||
47 | } |
||
48 | }); |
||
49 | |||
50 | var menuView = new view({ |
||
51 | model: model, |
||
52 | router: new Mn.AppRouter({ |
||
53 | controller: Controller(module, model) |
||
54 | }) |
||
55 | }); |
||
56 | |||
57 | this.app.showChildView('paymentMethodList', menuView); |
||
58 | } |
||
59 | }); |
||
60 | }); |
This requirement purely is a coding style requirement and is not required to run on JavaScript engines: